package thread;

public class Demo8 {
    //线程中断的两种写法：推荐Demo9写法

    private static boolean isFinish = false;

    public static void main(String[] args) throws InterruptedException {
        //boolean isFinish = false;
        Thread t = new Thread(()->{
            while(!isFinish){
                System.out.println("hello Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t.start();

        Thread.sleep(3000);
    }
}
